﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace ModelLibrary
{
    /// <summary>
    /// 缩放按钮
    /// </summary>

    public class DrawingZoomBtn
    {

        public DrawingZoomBtn(Control controls, Size sz, Brush brush, Brush brush2, Char LR)
        {
            using (Graphics g = controls.CreateGraphics())
            {
                using (Pen p = new Pen(brush))
                {
                    Point pt = new Point(controls.Width - 28, 0);

                    Rectangle rct = new Rectangle(pt, sz);
                    GraphicsPath gPath = new GraphicsPath(FillMode.Alternate);
                    rct.Inflate(-1, -1);
                    gPath.AddArc(rct, 30, 30);
                    gPath.AddArc(rct, 120, 30);
                    gPath.AddArc(rct, 210, 30);
                    gPath.AddArc(rct, 300, 30);
                    gPath.CloseAllFigures();
                    g.FillPath(brush, gPath);
                    rct.Inflate(rct.Size.Width / 2, rct.Size.Height / 2);
                    g.DrawPath(p, gPath);
                    p.Brush = brush2;
                    gPath.ClearMarkers();
                    if (LR == 'L')
                    {
                        gPath.AddLines(new Point[]
                        {
                        new Point(pt.X + sz.Width / 4 * 3, pt.Y + sz.Height / 4 * 1),
                        new Point(pt.X + sz.Width / 4 * 1, pt.Y + sz.Height / 4 * 2),
                        new Point(pt.X + sz.Width / 4 * 3, pt.Y + sz.Height / 4 * 3),
                        });
                    }
                    else if (LR == 'R')
                    {
                        gPath.AddLines(new Point[]
                       {
                        new Point(pt.X + sz.Width / 4 * 1+3, pt.Y + sz.Height / 4 * 1),
                        new Point(pt.X + sz.Width / 4 * 3+3, pt.Y + sz.Height / 4 * 2),
                        new Point(pt.X + sz.Width / 4 * 1+3, pt.Y + sz.Height / 4 * 3),
                       });
                    }
                    g.FillPath(brush2, gPath);
                    g.DrawPath(p, gPath);

                }
            }
        }
    }
}
